// Define common response apis
use axum::Json;
use serde::Serialize;
use serde_json::json;

pub fn ok() -> Json<serde_json::Value> {
    Json(json!({"success": true}))
}

pub fn ok_with_message(message: &str) -> Json<serde_json::Value> {
    Json(json!({"success": true, "message": message}))
}

pub fn ok_with_data<T>(data: T) -> Json<serde_json::Value>
where
    T: Serialize,
{
    Json(json!({"success": true, "data": data}))
}

pub fn ok_with_json(data: serde_json::Value) -> Json<serde_json::Value> {
    Json(json!({"success": true, "data": data}))
}

pub fn ok_with_message_data<T>(message: &str, data: T) -> Json<serde_json::Value>
where
    T: Serialize,
{
    Json(json!({"success": true, "message": message, "data": data}))
}

pub fn ok_with_message_json(message: &str, data: serde_json::Value) -> Json<serde_json::Value> {
    Json(json!({"success": true, "message": message, "data": data}))
}

pub fn error_with_message(message: &str) -> Json<serde_json::Value> {
    Json(json!({"success": false, "message": message}))
}
